package com.shu.map;

import java.math.BigDecimal;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import static java.math.BigDecimal.ROUND_UP;

/**
 * @author ssm
 * @version V1.0
 * @description:
 * @date 2020/8/3 15:11
 */

public class HashMapTest {


    public static void main(String[] args) {

        HashMap<String,Object> map = new HashMap<>();

        map.put("a1",1);
        map.put("a2",1);
        map.put("a3",1);
        map.put("a4",1);
        map.put("a5",1);
        map.put("a6",1);
        map.put("a7",1);
        map.put("a8",1);
        map.put("a9",1);
        map.put("a10",1);
        map.put("a11",1);
        map.put("a12",1);

        map.put("a13",1);
        map.put("a14",1);
        map.put("a15",1);
        map.put("a16",1);


        Map<Double,Object> map2 = new HashMap<>();

        map2.put(0.1D,1);
        System.out.println(map2.get(0.1D));
        System.out.println(map2.get(0.1d));
        System.out.println(map2.get("0.1"));

        System.out.println( 0 == 0D);
        System.out.println( 0.0 == 0d);
        System.out.println( 0.0d == 0D);


        System.out.println(new BigDecimal(0.1));
        System.out.println(new BigDecimal(0.1f));
        System.out.println(new BigDecimal(0.1F));
        System.out.println(new BigDecimal(0.1d));
        System.out.println(new BigDecimal(0.1D));
        System.out.println(new BigDecimal("0.1"));
        System.out.println(new BigDecimal(0.3));


        double d = 8d;
        long l = Double.doubleToLongBits(d);
        System.out.println(Long.toBinaryString(l));
        float f = 8;
        int i = Float.floatToIntBits(f);
        System.out.println(Integer.toBinaryString(i));


        BigDecimal num1 = new BigDecimal("1.0");
        BigDecimal num2 = new BigDecimal("3.0");
//        System.out.println(num1.divide(num2));
        System.out.println(num1.divide(num2,ROUND_UP));
        System.out.println(num1.divide(num2,2,BigDecimal.ROUND_DOWN));

        System.out.println(new BigDecimal(145.16).setScale(1,BigDecimal.ROUND_HALF_UP));
        System.out.println(new BigDecimal(145.16));

        applyStyles(EnumSet.of(Style.Red,Style.Blue));

    }

    public static void applyStyles(Set<Style> styles){
        styles.stream().forEach(System.out::println);
    }
    enum Style {
        Red,Blue,White;
    }
}
